//
//  XBViewController.m
//  XBRollingView
//
//  Created by liuboliu on 06/21/2021.
//  Copyright (c) 2021 liuboliu. All rights reserved.
//

#import "XBViewController.h"
#import <XBRollingView/XBRollingNoticeView.h>
#import "LXBCustomRollingCell.h"
#import "LXBBannerCell.h"

@interface XBViewController () <LXBRollingNoticeViewDelegate, XBRollingNoticeViewDataSource>

@end

@implementation XBViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor redColor];
    XBRollingNoticeView *rollView = [[XBRollingNoticeView alloc] initWithFrame:CGRectMake(10, 100, 300, 50)];
    [rollView registerClass:[LXBCustomRollingCell class] forCellReuseIdentifier:NSStringFromClass([LXBCustomRollingCell class])];
    [rollView registerClass:[LXBBannerCell class] forCellReuseIdentifier:NSStringFromClass([LXBBannerCell class])];
    rollView.animationDuration = 1;
    rollView.stayInterval = 3;
    rollView.fadeTranslationY = 10;
    ///渐隐轮播效果
    rollView.style = RollingStyleFade;
    rollView.style = RollingStyleScaleY;
    rollView.delegate = self;
    rollView.dataSource = self;
    [rollView reloadDataAndStartRoll];
    rollView.backgroundColor = [UIColor cyanColor];
    [self.view addSubview:rollView];
}

#pragma mark - LXBRollingNoticeViewDelegate, LXBRollingNoticeViewDelegate

- (XBNoticeViewCell *)rollingNoticeView:(XBRollingNoticeView *)rollingView cellAtIndex:(NSUInteger)index
{
//    if (index % 2 == 0) {
//        LXBBannerCell *cell = [rollingView dequeueReusableCellWithIdentifier:NSStringFromClass([LXBBannerCell class])];
//        return cell;
//    }
    LXBCustomRollingCell *cell = [rollingView dequeueReusableCellWithIdentifier:NSStringFromClass([LXBCustomRollingCell class])];
    [cell updateWithRow:index];
    return cell;
}

- (NSInteger)numberOfRowsForRollingNoticeView:(XBRollingNoticeView *)rollingView
{
    return 4;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
